﻿using Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    /// <summary>
    /// 部门表
    /// </summary>
    public class DepartmentDal:BaseDal<SysDepartment>
    {
        public override string tablename
        {
            get { return "SysDepartment"; }
        }

        public override Dictionary<string, bool> PKName
        {
            get
            {
                Dictionary<string, bool> dic = new Dictionary<string, bool>();
                dic.Add("department_Id", true);
                return dic;
            }
        }
        /// <summary>
        /// 获取部门表中的值 绑定下垃框
        /// </summary>
        /// <param name="UsersName"></param>
        /// <param name="UsersPwd"></param>
        /// <returns></returns>
        public List<SysDepartment> DepartmentBD()
        {
            string Sql = Common.Common.GetTable<SysDepartment>(tablename);
            DataTable dt = Common.DBHelp.GetDataSet(Sql);


            List<SysDepartment> dept = new List<SysDepartment>();
            foreach (DataRow item in dt.Rows)
            {
                SysDepartment dept1 = new SysDepartment();
                foreach (var i in dept1.GetType().GetProperties())
                {
                    i.SetValue(dept1, item[i.Name]);
                }
                dept.Add(dept1);
            }
            return dept;
        }
    }
}
